<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:marc="http://www.loc.gov/MARC21/slim"
                exclude-result-prefixes="marc">

    <xsl:output method="xml"
            encoding="UTF-8"
            indent="yes"
            doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
            doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
            />

    <xsl:param name="supplement"></xsl:param>
    <xsl:param name="area_name"></xsl:param>
    <xsl:param name="land_name"></xsl:param>
    <xsl:param name="land_path"></xsl:param>
    <xsl:param name="map_url"></xsl:param>
    <xsl:param name="collection_url"></xsl:param>
    <xsl:param name="aleph_url"></xsl:param>
    <xsl:param name="collection_signature"></xsl:param>
    <xsl:template match="/">        
        <xsl:call-template name="record"/>
    </xsl:template>




    <xsl:template name="record">
        
        <html>
            <head>
                <title>
                    <xsl:call-template name="pageTitle">
                        <xsl:with-param name="length">30</xsl:with-param>
                    </xsl:call-template>
                </title>
                <meta http-equiv="content-type" content="text/html; charset=utf-8" />
                <meta http-equiv="content-language" content="en" />
                <link rel="stylesheet" type="text/css" href="/style.css" media="screen" />
                <link rel="stylesheet" type="text/css" href="" media="print" />
                <meta name="author" content="" />
                <style type="text/css">
                    h1 {
                        line-height: 110%;
                        margin-left: 0px; margin-right: 0px; margin-top: 0px; margin-bottom: 10px;
                        display: block;
                        float: left;
                        text-align: left;
                        font-weight:normal;
                        color: #7a2b0a;
                        font-size:28px;
                        width:100%;
                    }

                    h2 {
                        margin-left: 0px; margin-right: 0px; margin-top: 2px; margin-bottom: 5px;
                        display: block;
                        float: left;
                        text-align: left;
                        font-weight:normal;
                        color: #333;
                        font-size:18px;
                        width:100%;
                    }

                    h3{
                        margin-left: 0px; margin-right: 0px; margin-top: 0px; margin-bottom: 8px;
                        display: block;
                        float: left;
                        text-align: left;
                        font-weight:normal;
                        color: #444;
                        font-size:12px;
                        width:100%;
                    }
                    #all #middlepanel .navigator li {
                        margin-right: 5px;
                    }

                </style>
<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-107343-8']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>
            </head>

            <body>
                <div id="all"/>
                <div id="middlepanel-images">
                    <div id="middlepanel">
                <!-- Header -->
                        <div class="header">
                            <div class="main-logo">
                                <h1>
                                    <a href="/">
                                        <img src="/images/logo-mapy.png" title="Mollova mapová sbírka" alt="Mollova mapová sbírka" />
                                    </a>
                                </h1>
                            </div>
                            <div class="menu-horizontal">
                                <ul>
                                    <li>
                                        <a href="/virtualni-vystavy/">Výstavy</a>
                                    </li>
                                    <li>
                                        <a href="/ostatni-sbirky-v-mzk/">Další fondy</a>
                                    </li>
                                    <li>
                                        <a href="/o-sbirce/">Historie</a>
                                    </li>
                                    <li>
                                        <a href="/mollova-sbirka/">Mollova sbírka</a>
                                    </li>
                                    <li>
                                        <a href="/hledat/">Hledat</a>
                                    </li>
                                    <li>
                                        <a href="/">Domů</a>
                                    </li>
                                </ul>
                            </div>
                            <div class="navigator"><ul></ul>
                                    <xsl:call-template name="navigator"/> 
                            </div>
                        </div>
                <!-- Header end -->
                <!-- Main historie -->
                        <div class="window-top"><xsl:comment></xsl:comment></div>
                        <div class="window">
                            <div class="mainpanel-center">
                                <xsl:call-template name="header"><xsl:with-param name="length">100</xsl:with-param></xsl:call-template>
                                <div class="content">


                                <xsl:if test="$supplement='no'">
                                    <xsl:call-template name="author"/>
                                    <xsl:call-template name="title"/>
                                </xsl:if>
                                    <table>
                                        <tr>
                                            <td>
                                                <OBJECT CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" CODEBASE="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" WIDTH="900" HEIGHT="700" ID="theMovie">
                                                    <param name="movie" value="zoomifyViewer.swf"/>
                                                    <PARAM NAME="MENU" VALUE="FALSE"/>
                                                    <param name="wmode" value="transparent"/>
                                                    <PARAM NAME="SRC" VALUE="zoomifyViewer.swf"/>
                                                    <EMBED FlashVars="zoomifyImagePath={$map_url}" WMODE="transparent" SRC="http://imageserver.mzk.cz/ZoomifyViewer.swf" MENU="FALSE" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"  BGCOLOR="#B88A00" WIDTH="900" HEIGHT="700" NAME="theMovie"/>
                                                </OBJECT>
                                            </td>
                                        </tr>
                                    </table>

                                    <xsl:if test="$supplement='no'">
                                    <xsl:call-template name="georeferencerLink"/>
                                    <xsl:call-template name="publishingData"/>
                                    <xsl:call-template name="geographicName"/>
                                    <br/>
                                    <xsl:call-template name="cooperativePersons"/>
                                    <xsl:call-template name="pieceName"/>
                                    
                                    <xsl:call-template name="generalNote"/>
                                    <xsl:call-template name="alephLink"/>
                                    </xsl:if>
                                    <!--<xsl:call-template name="bottomNavigation"/>-->

                                </div>

                            </div>
                        </div>
                        <div class="window-bottom"><xsl:comment></xsl:comment></div>
                    <!-- Main historie - end-->
                    <!-- Panel  Footer -->
                <div class="window-footer">
                    <div id="menu-footer">
                        <div class="copyright">
			  <a href="http://creativecommons.org/licenses/by-nc-nd/3.0/"><img alt="Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Unported License" style="border-width:0" src="http://i.creativecommons.org/l/by-nc-nd/3.0/80x15.png" /></a>
			</div>
                        <div class="links">
                            <ul>
                                <li><a href="mailto:Jiri.Dufka@mzk.cz">Webmaster</a></li>
                                <li><a href="http://www.facebook.com/pages/Moravsk%C3%A1-zemsk%C3%A1-knihovna/144194955037?v=wall"><img src="/images/ico-logo-fb.png" title="" alt="" /></a></li>
                                <li><a href="http://sites.google.com/site/mollovamapovasbirka/main-page-test/posts.xml"><img src="/images/ico-logo-rss.png" title="" alt="" /></a></li>
                            </ul>
                        </div>
                    </div>
                </div>
                <!-- Panel Footer end-->
                    </div>
                </div>
            </body>
        </html>
    </xsl:template>






    <xsl:template name="pageTitle">
        <xsl:param name="length"/>
        <xsl:param name="punctuation"><xsl:text>.:,;/]</xsl:text></xsl:param>
        <xsl:choose>
            <xsl:when test="$supplement='yes'">
                <xsl:value-of select="$collection_signature"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:variable name="title">
                    <xsl:choose>
                        <xsl:when test="not(substring(//marc:datafield[@tag='245']/marc:subfield[@code='a'],1,1)='[')">
                            <xsl:value-of select="//marc:datafield[@tag='245']/marc:subfield[@code='a']"/>
                        </xsl:when>
                        <xsl:when test="//marc:datafield[@tag='245']/marc:subfield[@code='p']">
                            <xsl:value-of select="//marc:datafield[@tag='245']/marc:subfield[@code='p']"/>
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:value-of select="//marc:datafield[@tag='245']/marc:subfield[@code='a']"/>
                        </xsl:otherwise>
                    </xsl:choose>
                </xsl:variable>

                <xsl:variable name="nameTitleChopFirst">
                    <xsl:choose>
                        <xsl:when test="substring(normalize-space($title),1,1)='['">
                            <xsl:value-of select="substring(normalize-space($title),2,string-length(normalize-space($title)) - 1)"/>
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:value-of select="$title"/>
                        </xsl:otherwise>
                    </xsl:choose>
                </xsl:variable>

                <xsl:variable name="nameTitleChopLast">
                    <xsl:choose>
                        <xsl:when test="contains($punctuation, substring(normalize-space($nameTitleChopFirst), string-length(normalize-space($nameTitleChopFirst)), 1))">
                            <xsl:value-of select="substring(normalize-space($nameTitleChopFirst),1,string-length(normalize-space($nameTitleChopFirst)) - 1)"/>
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:value-of select="$nameTitleChopFirst"/>
                        </xsl:otherwise>
                    </xsl:choose>
                </xsl:variable>

                <xsl:choose>
                    <xsl:when test="string-length(normalize-space($nameTitleChopLast)) &gt; $length">
                        <xsl:value-of select="substring(normalize-space($nameTitleChopLast),1,$length - 3)"/>...
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:value-of select="normalize-space($nameTitleChopLast)"/>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>



    <xsl:template name="header">
        <h1>
            <xsl:call-template name="pageTitle">
                <xsl:with-param name="length">80</xsl:with-param>
            </xsl:call-template>
        </h1>
    </xsl:template>




    <xsl:template name="author">
        <xsl:if test="//marc:datafield[@tag='100']">
        <h2>Autor:
            <xsl:value-of select="//marc:datafield[@tag='100']/marc:subfield[@code='a']"/><xsl:text> </xsl:text>
            <xsl:value-of select="//marc:datafield[@tag='100']/marc:subfield[@code='d']"/>
        </h2>
        </xsl:if>
    </xsl:template>



    <xsl:template name="title">
        <xsl:if test="//marc:datafield[@tag='245']">
        <p>
            <xsl:value-of select="//marc:datafield[@tag='245']/marc:subfield[@code='a']"/><xsl:text> </xsl:text>
            <xsl:if test="//marc:datafield[@tag='245']/marc:subfield[@code='b']">
                <xsl:value-of select="//marc:datafield[@tag='245']/marc:subfield[@code='b']"/><xsl:text> </xsl:text>
           </xsl:if>     
            <xsl:if test="//marc:datafield[@tag='245']/marc:subfield[@code='c']">                            
                <xsl:value-of select="//marc:datafield[@tag='245']/marc:subfield[@code='c']"/><xsl:text> </xsl:text>
           </xsl:if>            
            <xsl:if test="//marc:datafield[@tag='245']/marc:subfield[@code='n']">                            
                <xsl:value-of select="//marc:datafield[@tag='245']/marc:subfield[@code='n']"/><xsl:text> </xsl:text>
           </xsl:if>
           <xsl:if test="//marc:datafield[@tag='245']/marc:subfield[@code='p']">
                <p>
                <div style="font-style:italic">
                <xsl:value-of select="//marc:datafield[@tag='245']/marc:subfield[@code='p']"/>
                </div>
                </p>
           </xsl:if>
        </p>
        </xsl:if>
    </xsl:template>


    <xsl:template name="cooperativePersons">

        <xsl:if test="//marc:datafield[@tag='700']">
            <xsl:variable name="names">
                <xsl:for-each select="//marc:datafield[@tag='700']">
                    <xsl:value-of select="marc:subfield[@code='a']"/><xsl:text> </xsl:text>
                    <xsl:value-of select="marc:subfield[@code='d']"/>;
                </xsl:for-each>
            </xsl:variable>
            <p>Spolupracující osoby:
                <xsl:value-of select="substring(normalize-space($names), 1, string-length(normalize-space($names))-1)"/>.
            </p>
        </xsl:if>
    </xsl:template>




    <xsl:template name="publishingData">
        <xsl:if test="//marc:datafield[@tag='260']">
            <p>Nakladatelské údaje:
                <xsl:value-of select="//marc:datafield[@tag='260']/marc:subfield[@code='a']"/><xsl:text> </xsl:text>
                <xsl:value-of select="//marc:datafield[@tag='260']/marc:subfield[@code='b']"/><xsl:text> </xsl:text>
                <xsl:value-of select="//marc:datafield[@tag='260']/marc:subfield[@code='c']"/>
                <xsl:value-of select="//marc:datafield[@tag='260']/marc:subfield[@code='e']"/>
                <xsl:value-of select="//marc:datafield[@tag='260']/marc:subfield[@code='f']"/>
                <xsl:value-of select="//marc:datafield[@tag='260']/marc:subfield[@code='g']"/>
            </p>
        </xsl:if>
    </xsl:template>


    <xsl:template name="pieceName">
        <xsl:if test="//marc:datafield[@tag='505']">
            <p>Název části díla:
                <xsl:for-each select="//marc:datafield[@tag='505']">
                    <xsl:value-of select="marc:subfield[@code='t']"/>
                </xsl:for-each>
            </p>
        </xsl:if>
    </xsl:template>



    <xsl:template name="geographicName">
        <xsl:if test="//marc:datafield[@tag='651']">
            <xsl:variable name="names">
                <xsl:for-each select="//marc:datafield[@tag='651']">
                    <xsl:value-of select="marc:subfield[@code='a']"/>,
                    </xsl:for-each>
            </xsl:variable>
            <p>Zeměpisné určení:
                <xsl:value-of select="substring(normalize-space($names), 1, string-length(normalize-space($names))-1)"/>.
            </p>
        </xsl:if>


    </xsl:template>

    <xsl:template name="generalNote">
        <xsl:if test="//marc:datafield[@tag='500']">
            <p>
                <xsl:for-each select="//marc:datafield[@tag='500']">
                    <xsl:apply-templates/>
                </xsl:for-each>
            </p>
        </xsl:if>
    </xsl:template>





    <xsl:template name="alephLink">
        <div style="float:right;">
            <a href="{$aleph_url}">Bibliograficky zaznam v knihovnim katalogu</a>
        </div>
    </xsl:template>



    <xsl:template name="georeferencerLink">
        <xsl:if test="substring(//marc:controlfield[@tag='007']/text(),1,2)='aj'">
            <center>
                <a href="http://www.georeferencer.org/georeference/">View at Georeferencer.org</a>
            </center>
        </xsl:if>
    </xsl:template>




    <xsl:template name="bottomNavigation">
        <p>
        <table width="100%">
            <tr>
                <td>
                    <a href="">předchozí</a>
                </td>
                <td align="center">
                    <a href="{$collection_url}">zpět</a>
                </td>
                <td align="right">
                    <a href="">následující</a>
                </td>
            </tr>
        </table>
        </p>
    </xsl:template>


    <xsl:template name="navigator">
        <ul>
            <li>
                <a href="/mollova-sbirka/">Mollova sbírka</a>
            </li>
            <li>></li>
            <li>
                <a href="/mollova-sbirka/{$land_path}/">
                    <xsl:value-of select="$land_name"/>
                </a>
            </li>
            <li>></li>
            <li>
                <a href="{$collection_url}">
                    <xsl:value-of select="$area_name"/>
                </a>
            </li>
            <li>></li>            
            <li>
                <xsl:call-template name="pageTitle">
                    <xsl:with-param name="length">40</xsl:with-param>
                </xsl:call-template>
            </li>
        </ul>
    </xsl:template>


</xsl:stylesheet>
